package routes

import (
	"github.com/kataras/iris/v12"
	"my_iris/global"
)

// 前台视图路由: http://{host}/
func Route(r iris.Party) {
	// [首页]
	// /index
	r.Get("/", RouteIndex{}.Index)
	r.Get("/index", RouteIndex{}.Index)
	r.Get("/version", RouteIndex{}.Version)
}

// RouteIndex
type RouteIndex struct {
}

func (p RouteIndex) Index(ctx iris.Context) {
	_ = ctx.View("index/index.html")
}

func (p RouteIndex) Version(ctx iris.Context) {
	ret := iris.Map{
		"BuildTime":      global.BuildTime,
		"BuildGoVersion": global.BuildGoVersion,
		"SiteName":       global.SiteConf.SiteName,
	}
	_, _ = ctx.JSON(ret)
	return
}
